// ============================== 导入依赖 ============================== //

import CORE from '@login/CORE'
import TRANS from '@demo/CORE/UTIL/init/TRANS'

import Client from '@api/base/api/SysDictApi'

import TreeClass from '@api/base/model/SysDictQueryDto'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 结构树 —————————————————————————————— //

  async getDict(name = '字典') {
    if (sessionStorage.DICT) return JSON.parse(sessionStorage.DICT)

    const DTO = CORE.grpcDTO(TreeClass)
    const resp = await CORE.grpc(TRANS.transTip(name), CLIENT, 'sysDictQuery', DTO)
    const DICT = resp.content || []

    sessionStorage.DICT = JSON.stringify(DICT)

    return DICT
  },
}
